.class public Lcom/sponsorpay/sdk/android/credentials/SPCredentials;
.super Ljava/lang/Object;
.source "SPCredentials.java"


# instance fields
.field private final mAppId:Ljava/lang/String;

.field private final mCredentialsToken:Ljava/lang/String;

.field private final mHostInfo:Lcom/sponsorpay/sdk/android/utils/HostInfo;

.field private mSecurityToken:Ljava/lang/String;

.field private final mUserId:Ljava/lang/String;


# direct methods
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V
    .locals 2
    .parameter "appId"
    .parameter "userId"
    .parameter "securityToken"
    .parameter "context"

    .prologue
    .line 38
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 39
    invoke-static {p1}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->nullOrEmpty(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 40
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "AppID cannot be null!"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 42
    :cond_0
    invoke-static {p3}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->trim(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mSecurityToken:Ljava/lang/String;

    .line 43
    new-instance v0, Lcom/sponsorpay/sdk/android/utils/HostInfo;

    invoke-direct {v0, p4}, Lcom/sponsorpay/sdk/android/utils/HostInfo;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mHostInfo:Lcom/sponsorpay/sdk/android/utils/HostInfo;

    .line 44
    invoke-static {p1}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->trim(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mAppId:Ljava/lang/String;

    .line 45
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mAppId:Ljava/lang/String;

    invoke-static {v0, p2}, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->getCredentialsToken(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mCredentialsToken:Ljava/lang/String;

    .line 46
    invoke-static {p2}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->nullOrEmpty(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 47
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mHostInfo:Lcom/sponsorpay/sdk/android/utils/HostInfo;

    invoke-static {p4, v0}, Lcom/sponsorpay/sdk/android/utils/UserId;->getAutoGenerated(Landroid/content/Context;Lcom/sponsorpay/sdk/android/utils/HostInfo;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mUserId:Ljava/lang/String;

    .line 51
    :goto_0
    return-void

    .line 49
    :cond_1
    iput-object p2, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mUserId:Ljava/lang/String;

    goto :goto_0
.end method

.method public static getCredentialsToken(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 3
    .parameter "appId"
    .parameter "userId"

    .prologue
    .line 121
    invoke-static {p0}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->nullOrEmpty(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 122
    new-instance v1, Ljava/lang/IllegalArgumentException;

    const-string v2, "AppID cannot be null!"

    invoke-direct {v1, v2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 124
    :cond_0
    invoke-static {p1}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->nullOrEmpty(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 125
    const-string p1, ""

    .line 127
    :cond_1
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-static {p0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v2, "-"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 128
    .local v0, token:Ljava/lang/String;
    invoke-virtual {v0}, Ljava/lang/String;->getBytes()[B

    move-result-object v1

    invoke-static {v1}, Ljava/util/UUID;->nameUUIDFromBytes([B)Ljava/util/UUID;

    move-result-object v1

    invoke-virtual {v1}, Ljava/util/UUID;->toString()Ljava/lang/String;

    move-result-object v1

    return-object v1
.end method


# virtual methods
.method public getAppId()Ljava/lang/String;
    .locals 1

    .prologue
    .line 68
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mAppId:Ljava/lang/String;

    return-object v0
.end method

.method public getCredentialsToken()Ljava/lang/String;
    .locals 1

    .prologue
    .line 59
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mCredentialsToken:Ljava/lang/String;

    return-object v0
.end method

.method public getHostInfo()Lcom/sponsorpay/sdk/android/utils/HostInfo;
    .locals 1

    .prologue
    .line 106
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mHostInfo:Lcom/sponsorpay/sdk/android/utils/HostInfo;

    return-object v0
.end method

.method public getSecurityToken()Ljava/lang/String;
    .locals 1

    .prologue
    .line 87
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mSecurityToken:Ljava/lang/String;

    return-object v0
.end method

.method public getUserId()Ljava/lang/String;
    .locals 1

    .prologue
    .line 78
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mUserId:Ljava/lang/String;

    return-object v0
.end method

.method public setSecurityToken(Ljava/lang/String;)V
    .locals 0
    .parameter "securityToken"

    .prologue
    .line 97
    iput-object p1, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mSecurityToken:Ljava/lang/String;

    .line 98
    return-void
.end method

.method public toString()Ljava/lang/String;
    .locals 4

    .prologue
    .line 134
    const-string v1, "Credentials token - %s\nAppId - %s\nUserId - %s\nSecurityToken - %s"

    const/4 v0, 0x4

    new-array v2, v0, [Ljava/lang/Object;

    const/4 v0, 0x0

    .line 135
    iget-object v3, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mCredentialsToken:Ljava/lang/String;

    aput-object v3, v2, v0

    const/4 v0, 0x1

    .line 136
    iget-object v3, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mAppId:Ljava/lang/String;

    aput-object v3, v2, v0

    const/4 v3, 0x2

    .line 137
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mUserId:Ljava/lang/String;

    invoke-static {v0}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->notNullNorEmpty(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mUserId:Ljava/lang/String;

    :goto_0
    aput-object v0, v2, v3

    const/4 v3, 0x3

    .line 138
    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mSecurityToken:Ljava/lang/String;

    invoke-static {v0}, Lcom/sponsorpay/sdk/android/utils/StringUtils;->notNullNorEmpty(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_1

    iget-object v0, p0, Lcom/sponsorpay/sdk/android/credentials/SPCredentials;->mSecurityToken:Ljava/lang/String;

    :goto_1
    aput-object v0, v2, v3

    .line 134
    invoke-static {v1, v2}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    .line 133
    return-object v0

    .line 137
    :cond_0
    const-string v0, "N/A"

    goto :goto_0

    .line 138
    :cond_1
    const-string v0, "N/A"

    goto :goto_1
.end method
